//店面管理-排期列表
App.util.ns('Admin.Storefront.Schedule');
App.pages.add((function(){
    var NS = Admin.Storefront.Schedule;
    var page = new App.Page({
        name: 'storefront/schedule/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-gg"></i>',
            content: '店面管理'
        }, {
            content: '商品排期'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/storefront/schedule',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'status', title: '状态', width: '120px', items: [
                    [0, '待更新柜体商品'],
                    [1, '上线'],
                    [2, '下线']
                ]}
            ],
            menu: [
                {parent: 'add', permission: 'op:admin.storefront.schedule.create'},
                //{parent: 'view', permission: 'op:admin.storefront.schedule.detail'},
                {parent: 'edit', permission: 'op:admin.storefront.schedule.update'},
                {type: 'inline', permission: 'op:admin.storefront.schedule.offline',
                    name: '下线',
                    operation: {type: 'change', url: 'offline'},
                    conditions: [['status', '1']]
                },
                {
                    type: 'inline',
                    name: '格子分布',
                    icon: '<i class="fa fa-random"></i>',
                    floatable: true,
                    permission: 'gp:admin/storefront/schedule',
                    operation: function(dataTable, schedule){
                        var win = dataTable.wins.get('schedulegoods').show();
                        win.changeSchedule(schedule);
                        win.show();
                    }
                },
                {type: 'inline', permission: 'op:admin.storefront.schedule.applicationx', name: '应用',
                    operation: {type: 'change', url: 'applicationx'},
                    conditions: [['status', '0']]
                },
                {parent: 'drop', permission: 'op:admin.storefront.schedule.delete'},
                {parent: 'multiDrop', permission: 'op:admin.storefront.schedule.multiDelete'},
                {parent: 'oplog', permission: 'op:admin.storefront.schedule.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form)
                }
            },
            after: function(dataTable){
                dataTable.wins.add(new NS.Schedulegoods(dataTable), 'schedulegoods');
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());